<template>
  <div class="component-teamProject">
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>施工队考勤总览
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="$router.go(0)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>
    <div class="component-searchHeader">
      <div class="search-header">
        <div class="left-title">
          <p class="left-text">
            <span class="iconfont" style="font-weight:700">&#xe63d;</span>筛选查询
          </p>
          <div class="right">
            <button @click="findRes">查询</button>
          </div>
        </div>
      </div>
    </div>
    <div class="component-search-box">
      <el-form :inline="true" :model="teamSearch" class="demo-form-inline">
        <el-form-item v-show="ms_roleName == 'CenterClerk' && ms_roleName == 'CenterDeputy' && ms_roleName == 'CenterFinanceClerk' && ms_roleName == 'CenterFinanceManager' && ms_roleName == 'CenterBOSS'" label="项目部：" style="width:325px;">
          <el-select v-model="teamSearch.pro" clearable placeholder="请选择项目部">
            <el-option v-for="(item,index) in proList" :key="index" :label="item.orgName" :value="item.orgId"></el-option>
          </el-select>
        </el-form-item>

    <el-form-item label="选择日期：" style="width:500px;margin-left: -43px;">
          <el-date-picker
            v-model="teamSearch.date"
            type="daterange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="timestamp"
            :default-time="['00:00:00', '23:59:59']">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="施工队长：" style="width:325px;">
          <el-select clearable v-model="teamSearch.team" placeholder="请选择施工队长">
            <el-option v-for="(item,index) in teamList" :key="index" :label="item.userTrueName" :value="item.userId"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>

    <div class="component-listHeader">
      <div class="search-header">
        <div class="left-title">
          <p class="left-text">
            <span class="iconfont">&#xe61e;</span>
            负责项目
          </p>
          <div class="right">
          </div>
        </div>
      </div>
    </div>

    <div class="table">
      <el-table
        ref="multipleTable"
        :data="teamInfo"
        tooltip-effect="dark"
        style="width: 1100px;margin:0 auto"
        border
      >
        <el-table-column label="时间" align="center" prop="gps_time">
          <template slot-scope="scope">
            {{scope.row.gpsTime | dateFilter}}
          </template>
        </el-table-column>
        <el-table-column label="施工队名称" align="center" prop="orgName"></el-table-column>
        <el-table-column label="施工队队长" align="center" prop="userTruename"></el-table-column>
        <el-table-column label="考勤地址" align="center" prop="POSITION"></el-table-column>
      </el-table>
    </div>
    <div class="component-paging" v-if="teamInfo.length > 0">
      <div class="table-bottom">
        <div class="bottom-left" style="margin-left: 42px;"></div>
        <div class="paging">
          <div class="paging-left">
            <p>
              共
              <span>{{Math.ceil(total/pageSize)}}</span> 页/
              <span>{{total}}</span> 条数据
            </p>
          </div>
          <el-pagination
            background
            @size-change="SizeChange($event,dataInit,currentPage,pageSize)"
            @current-change="CurrentChange($event,dataInit,currentPage,pageSize)"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30]"
            :page-size="pageSize"
            layout="sizes, prev, pager, next, jumper"
            :total="total"
          ></el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "teamCalc",
  data() {
    return {
      ms_roleName:localStorage.getItem("roleName"),
      teamSearch: {
        area: "",
        team: "",
        date:[]
      },
      teamInfo: [],
      total: 1,
      // 每页显示数据的条数
      pageSize: 10,
      // 当前显示的页面页码
      currentPage: 1,
      teamList:[],//施工队列表
      proList:[],//项目部列表
    };
  },
  mounted(){
    this.dataInit("","");
    this.teamLists(); //施工队列表
    this.proLists();//项目列表
  },
  methods: {
    //项目部列表
    proLists(){
      let that = this;
      let suCb = function(res){
        that.proList = res.data.data;
        console.log(res.data)
      }
      let erCb = function(res){
        console.log(res)
      }
      let postData = {
      }
      let palyParam = {
        url: "/api/web/proTeam/getDeparName",
        methods:'post',
        data: postData,
        success: suCb,
        error: erCb,
      }
      that.$https(palyParam)
    },
    //点击查询
    findRes(){
      this.currentPage = 1;
      this.dataInit();
    },
    dataInit(){
      var dateArr = ["",""];
      if(this.teamSearch.date!=undefined){
        dateArr = this.teamSearch.date;
      }
      let that = this;
      let suCb = function(res){
        that.teamInfo = res.data.data.records;
        that.total = res.data.data.rowCount;
        console.log(res.data.data)
      }
      let erCb = function(res){
        console.log(res)
      }
      let postData = {
        pageCurrent: that.currentPage.toString(),
        pageSize:that.pageSize.toString(),
        leaderName: that.teamSearch.team,
        startTime: dateArr[0]!=undefined?dateArr[0]+"":"",
        endTime: dateArr[1]!=undefined?dateArr[1]+"":"",
        orgId:that.teamSearch.pro
      }
      let palyParam = {
        url: "/api/web/proWorkAttend/getProWorkAttend",
        methods:'post',
        data: postData,
        success: suCb,
        error: erCb,
      }
      that.$https(palyParam)
    },
    //获取施工队列表
    teamLists(){
      let that = this;
      let suCb = function(res){
        that.teamList = res.data.data
        console.log(that.teamList)
      }
      let erCb = function(res){
        console.log(res)
      }
      let postData = {}
      let palyParam = {
        url: "/api/web/proTeam/getTeamList",
        methods:'post',
        data: postData,
        success: suCb,
        error: erCb,
      }
      that.$https(palyParam)
    },
  }
};
</script>

<style scoped>
.component-searchHeader .search-header {
  width: 1100px;
  box-sizing: border-box;
  border: 1px solid rgba(228, 228, 228, 1);
  background-color: rgba(255, 255, 255, 1);
  margin: 20px auto 0;
}

.component-searchHeader .search-header .left-title {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background-color: rgba(243, 243, 243, 1);
  height: 45px;
  box-sizing: border-box;
}

.component-searchHeader .search-header .left-title .left-text {
  width: 20%;
  color: #666;
  line-height: 45px;
  font-family: "微软雅黑";
  font-weight: 400;
  font-size: 12px;
  text-align: left;
  margin: 0 0 0 30px;
}

.component-searchHeader .right {
  width: 70%;
  display: flex;
  justify-content: flex-end;
  margin-right: 30px;
}

.component-searchHeader .right button {
  padding: 0 25px;
  height: 30px;
  margin: 8px 5px;
  line-height: 30px;
  font-size: 14px;
  color: #666;
  background-color: #fff;
  border: 1px solid #ccc;
}

.component-searchHeader .right button:hover {
  background-color: #f3f3f3;
  cursor: pointer;
}
.component-search-box {
  width: 1100px;
  box-sizing: border-box;
  background-color: #fff;
  border: 1px solid #e4e4e4;
  border-top: none;
  margin: 0 auto;
  text-align: left;
  padding-left: 30px;
  line-height: 60px;
  padding-bottom: 15px;
  padding-top: 15px;
}
.component-search-box .el-input__inner {
  height: 35px;
  display: inline-block;
}
.el-form-item {
  margin-bottom: 0;
}
.component-listHeader .search-header {
  width: 1100px;
  box-sizing: border-box;
  border: 1px solid rgba(228, 228, 228, 1);
  border-bottom: none;
  background-color: rgba(255, 255, 255, 1);
  margin: 20px auto 0;
}

.component-listHeader .search-header .left-title {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background-color: rgba(243, 243, 243, 1);
  height: 45px;
  box-sizing: border-box;
}

.component-listHeader .search-header .left-title .left-text {
  width: 20%;
  color: #666;
  line-height: 45px;
  font-family: "微软雅黑";
  font-weight: 400;
  font-size: 12px;
  text-align: left;
  margin: 0 0 0 30px;
}

.component-listHeader .search-header .right {
  width: 70%;
  display: flex;
  justify-content: flex-end;
  margin-right: 10px;
}

.component-listHeader .search-header .right button {
  padding: 0 15px;
  height: 30px;
  width: 110px;
  margin: 6px 5px;
  line-height: 30px;
  font-size: 14px;
  color: #1abc9c;
  background-color: #fff;
  border: 1px solid #ccc;
}
.el-form-item {
  text-align: right;
  width: 310px;
}
.component-listHeader .search-header .right button:hover {
  background-color: #1abc9c;
  color: #fff;
}
.component-listHeader .search-header .right .right-select-margin {
  margin-top: 8px;
  margin-right: 8px;
}
/* 删除按钮 */
.red {
  color: #48c9b0;
  font-size: 12px;
}

.component-search-box .el-input__inner {
    height: 36px;
    display: inline-block;
    vertical-align: middle;
}
</style>
